CREATE  TABLE `Applications` (`ID` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT ,`ApplicationName` VARCHAR(45) NULL , PRIMARY KEY (`ID`) );

CREATE TABLE `Errors` (
  `ErrorID` VARCHAR(45) NOT NULL,
  `Application` INTEGER UNSIGNED NOT NULL,
  `Host` VARCHAR(50) NOT NULL,
  `Type` VARCHAR(100) NOT NULL,
  `Source` VARCHAR(60) NOT NULL,
  `Message` VARCHAR(500) NOT NULL,
  `UserName` VARCHAR(50) NOT NULL,
  `StatusCode` INTEGER UNSIGNED NOT NULL,
  `TimeUtc` DATETIME NOT NULL,
  `Details` LONGTEXT NOT NULL,
  PRIMARY KEY (`ErrorID`),
  CONSTRAINT `FK_Errors_Applications` FOREIGN KEY `FK_Errors_Applications` (`Application`)
    REFERENCES `applications` (`ID`)
    ON DELETE CASCADE
    ON UPDATE CASCADE
)
ENGINE = InnoDB;